package org.dinner.order.service.impl;

import java.util.Date;
import java.util.List;

import org.dinner.order.dao.MenuDAO;
import org.dinner.order.model.Dish;
import org.dinner.order.model.Menu;
import org.dinner.order.service.MenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class MenuServiceImpl implements MenuService {

	@Autowired
	private MenuDAO menuDAO;
	
	@Transactional
	public Menu add(Menu item) {
		return menuDAO.add(item);
	}
	
	@Transactional
	public List<Menu> list() {
		return menuDAO.list();
	}

	@Transactional
	public Menu getById(int id) {
		return menuDAO.getById(id);
	}

	@Transactional
	public void remove(int id) {
		menuDAO.remove(id);
	}

	@Transactional
	public Menu getByDate(Date date) {
		return menuDAO.getByDate(date);
	}

	@Transactional
	public Menu createMenu(Date date, List<Dish> dishes) {
		return menuDAO.createMenu(date, dishes);
	}

	@Transactional
	public void addDish(int menuId, int dishId) {
		menuDAO.addDish(menuId, dishId);
	}

}
